import KZJRequest from '../index'
import { TRequestDefaultResult } from '../type'

enum Song {
  SongSheets = '/playlist/track/all', // 歌单对应数据
  SongComment = '/comment/playlist', // 歌单对应评论
  SentComment = '/comment', // 发布评论
  SongCollect = '/playlist/subscribers' // 歌单收藏者
}

export function getSongSheets(id: number) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Song.SongSheets,
    params: { id },
    showLoading: true
    // takeCookie: true
  })
}
// 获取用户喜欢的歌单
export function getSongSheetsLike(id: number) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Song.SongSheets,
    params: { id },
    showLoading: true,
    takeCookie: true
  })
}

export function getSongComment(id: number, offset = 0, limit = 30) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Song.SongComment,
    params: { id, limit, offset },
    showLoading: true
  })
}

export function sentComment(
  id: number | string,
  content: string,
  t = 1, // 1 发送 2 回复
  type = 2 //歌曲0 MV1 歌单2 专辑3 电台4 视频5 动态6
) {
  return KZJRequest.post<TRequestDefaultResult>({
    url: Song.SentComment,
    data: { t, type, id, content },
    takeCookie: true,
    showLoading: true
  })
}

export function getSongCollect(id: number, offset = 0, limit = 30) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Song.SongCollect,
    params: { id, limit, offset },
    showLoading: true
  })
}
